package service.impl;

import dao.SuppDao;
import dao.impl.SuppDaoImpl;
import entity.Supp;
import service.SuppService;

public class SuppServiceImpl implements SuppService {

	SuppDao dao = new SuppDaoImpl();

	@Override
	public boolean save(Supp supp) {
		// 在服务层做非空验证
		if (supp.getSuppid() != null &&  supp.getSuppname() !=null && supp.getSupparea() != null  
				&& supp.getContact() != null && supp.getMobile() != null) {
			
			String evalevel = supp.getEvalevel();
			if (evalevel != null) {
				switch(evalevel) {
				case "01":
				case "02":
				case "03":
				case "04":return dao.insert(supp);
				default : return false;
				}
			}
			return dao.insert(supp);
		} else { 
			return false;
		}
	}

	@Override
	public boolean modifyLevelById(String suppid,String evalevel) {
		if (suppid != null && evalevel != null) {
			return dao.updateLevelById(suppid,evalevel);
		} else {
			return false;
		}
	}

}
